package com.th.coupon.feign;

import com.th.coupon.common.vo.CommonResponse;
import com.th.coupon.common.vo.CouponTemplateSdk;
import com.th.coupon.feign.hystrix.TemplateClientHystrix;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Collection;
import java.util.List;
import java.util.Map;

/**
 * 调用优惠卷模板微服务
 * @author 涂航
 */
@FeignClient(value = "coupon-template-service",fallback = TemplateClientHystrix.class )
public interface TemplateClient {


    /**
     * 获取所有可用的优惠卷模板信息
     * @return {@link List} 优惠卷模板实体集
     */
    @RequestMapping(value = "/coupon-template/template/sdk/all"
            ,method = RequestMethod.GET)
    CommonResponse<List<CouponTemplateSdk>> findAllUsableTemplate();

    /**
     * 查询id与优惠卷模板的映射
     * @param ids 优惠卷模板id集合
     * @return {@link Map}
     */
    @RequestMapping(value = "/coupon-template/template/sdk/infos"
            ,method = RequestMethod.GET)
    CommonResponse<Map<Integer,CouponTemplateSdk>> findIds2TemplateSdk(@RequestParam("ids") Collection<Integer> ids);

}
